home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / ev_201.zip / TWINDOW.HPP < prev   
C/C++ Source or Header  |  1993-07-03  |  15KB  |  331 lines

  1. #if !defined (TWINDOW)               // Prevents multiple declarations errors
  2. #define TWINDOW
  3.  
  4.  
  5. /*
  6.    Module        : TWINDOW.HPP
  7.    Version       : 2.0
  8.    Revision date : July 3rd, 1993
  9.    Author(s)     : Remy Gendron
  10.  
  11.    Description   : Header file of {twindow} class.
  12. */
  13.  
  14.  
  15. // Headers ------------------------------------------------------------------
  16.  
  17. #include <conio.h>                                     // System's librairies
  18. #include <stdio.h>
  19. #include <values.h>
  20.  
  21. #include "tinput.hpp"                                        // Other modules
  22.  
  23.  
  24. // Macros -------------------------------------------------------------------
  25.  
  26. #include "stdmacro.h"                           // Standard macro definitions
  27.  
  28.  
  29. // TypeDefs -----------------------------------------------------------------
  30.  
  31. #include "stdtype.h"                             // Standard type definitions
  32.  
  33.  
  34. struct tbutton                                         // Button's definition
  35. {
  36.    char    huge *buttonname ;                                // Button's name
  37.    int          buttonkey ;              // Key code that 'pushes' the button
  38.    int          buttonrow ;                         // Button's row in window
  39.    int          buttoncol ;                         // Button's col in window
  40.    bool         buttonavail ;                    // TRUE: Button is available
  41.    char    huge *buttonsltext ;                   // Button's statusline text
  42.    int          buttonhlpctx ;                // Button's help context number
  43.    tbutton huge *buttonnext ;                   // Ptr to next button in link
  44.    tbutton huge *buttonprevious ;           // Ptr to previous button in link
  45. } ;
  46.  
  47.  
  48. struct tfield                                     // Input field's definition
  49. {
  50.    int          fieldnumber ;                   // Input field's ID # ([1..[)
  51.    char   huge  *fieldanswer ;                      // Ptr to answer's buffer
  52.    int          fieldanswerlength ;                    // Answer's max length
  53.    int          fieldlength ;                         // Input field's length
  54.    int          fieldrow ;                           // Field's row in window
  55.    int          fieldcol ;                           // Field's col in window
  56.    int          fieldftr ;                     // Filter used for input (0-4)
  57.    char   huge  *fieldxtraftr ;               // Extra chars to use as filter
  58.    bool         fieldcapsflag ;             // If TRUE, switches to uppercase
  59.    bool         fieldnullflag ;           // If TRUE, can enter a null string
  60.    char   huge  *fieldsltext ;                     // Field's statusline text
  61.    int          fieldhlpctx ;                  // Field's help context number
  62.    tfield huge  *fieldnext ;                     // Ptr to next field in link
  63.    tfield huge  *fieldprevious ;             // Ptr to previous field in link
  64. } ;
  65.  
  66.  
  67. // Prototypes ---------------------------------------------------------------
  68.  
  69. class twindow
  70. {
  71.    char    huge *winunder ;     // Ptr to buffer to saved screen under window
  72.    char    huge *winrshadow ;       // Ptr to buffer to saved right of window
  73.    char    huge *winrshadowd ;             // Ptr to buffer with right shadow
  74.    char    huge *winbshadow ;       // Ptr to buffer to save bottom of window
  75.    char    huge *winbshadowd ;            // Ptr to buffer with bottom shadow
  76.    char    huge *winfront ;       // Ptr to save window's content when hidden
  77.    char    huge *wintitle ;                          // Ptr to window's title
  78.    int          winhlpctx ;         // Window's context sensitive help number
  79.    twindow huge *winnext ;                             // Next window in link
  80.    twindow huge *winprevious ;                     // Previous window in link
  81.    int          winrow ;                // Window's position (topleft corner)
  82.    int          wincol ;                // Window's position (topleft corner)
  83.    int          winheight ;                        // Window's height in rows
  84.    int          winwidth ;                       // Window's width in columns
  85.    int          winbackcolor ;                   // Window's background color
  86.    int          winforecolor ;                   // Window's foreground color
  87.    int          wincurrow ;                    // Cursor's position in window
  88.    bool         winmovable ;                     // TRUE: Window can be moved
  89.    int          winstatus ;                       // 0:closed 1:open 2:hidden
  90.  
  91.                // The following attributes apply to all existing input fields
  92.  
  93.    int          dfieldbackcolor ;         // Default field's background color
  94.    int          dfieldforecoloron ;       // Default field's foreground color
  95.    int          dfieldforecoloroff ;
  96.    int          fieldcount ;                // Number of input fields created
  97.    tfield  huge *fieldfirst ;                          // First field in link
  98.    tfield  huge *fieldlast ;                            // Last field in link
  99.  
  100.                     // The following attributes apply to all existing buttons
  101.  
  102.    int          buttonbackcolor ;                // Buttons' background color
  103.    int          buttonforecoloron ;       // Active buttons' foreground color
  104.    int          buttonforecoloroff ;    // Inactive buttons' foreground color
  105.    int          buttonhighcolor ;                 // Button's highlight color
  106.    tbutton huge *buttonfirst ;                        // First button in link
  107.    tbutton huge *buttonlast ;                          // Last button in link
  108.  
  109.    int          screenheight ;                        // Current screenheight
  110.    int          screenwidth ;                          // Current screenwidth
  111.  
  112.  
  113.    public:
  114.  
  115. far twindow () ;                                               // Constructor
  116.  
  117. far ~twindow () ;                                               // Destructor
  118.  
  119. void far twindow::winsetpos                  // Sets window's screen position
  120. (
  121.    int  row,                                         // Top left corner's row
  122.    int  col,                                         // Top left corner's col
  123.    bool movable=EV_MAYBE  // TRUE: Window can be moved.  Default is no change
  124. ) ;
  125.  
  126. int far twindow::wingetrow () ;                   // Returns window's row pos
  127.  
  128. int far twindow::wingetcol () ;                   // Returns window's col pos
  129.  
  130. void far twindow::winsetsize                            // Sets window's size
  131. (
  132.    int height=MAXINT,                     // Window's height including frames
  133.    int width=MAXINT                        // Window's width including frames
  134. ) ;
  135.  
  136. int far twindow::wingetheight () ;                 // Returns window's height
  137.  
  138. int far twindow::wingetwidth () ;                   // Returns window's width
  139.  
  140. void far twindow::winsetcolors                        // Sets window's colors
  141. (
  142.    int back=LIGHTGRAY,                           // Window's background color
  143.    int fore=WHITE                                // Window's foreground color
  144. ) ;
  145.  
  146. void far twindow::winsettitle                          // Sets window's title
  147. (
  148.    char huge *title                                  // Ptr to window's title
  149. ) ;
  150.  
  151. void far twindow::winsethlpctx          // Sets general help context's number
  152. (
  153.    int hlpctx=EV_NOHLPCTX                            // Help context's number
  154. ) ;
  155.  
  156. void far twindow::winopen () ;          // Opens window with current settings
  157.  
  158. void far twindow::winclose () ;                   // Closes and resets window
  159.  
  160. void far twindow::winclear                        // Clears an area in window
  161. (
  162.    int left=1,                                             // Top left corner
  163.    int top=1,
  164.    int right=MAXINT,                                   // Bottom right corner
  165.    int bottom=MAXINT
  166. ) ;
  167.  
  168. void far twindow::winwrite                           // Writes text to window
  169. (
  170.    char huge *text,                              // Ptr to text to be written
  171.    int  row=EV_DEF,                              // Text's position in window
  172.    int  col=1,
  173.    int  format=0,          // Justification  0:none 1:left 2:centered 3:right
  174.    int  fore=EV_DEF,                                          // Text's color
  175.    int  back=EV_DEF
  176. ) ;
  177.  
  178. void far twindow::wintext                 // Displays text with word wrapping
  179. (
  180.    char huge *textptr,                         // Ptr to text to be displayed
  181.    int       fore=EV_DEF,                   // Text's normal foreground color
  182.    int       high=YELLOW                            // Text's highlight color
  183. ) ;
  184.  
  185. void far twindow::wintextfile                         // Displays a text file
  186. (
  187.    char huge *path,                                           // Path to file
  188.    int       fore=EV_DEF,                          // Foreground color to use
  189.    int       high=YELLOW                            // Highlight color to use
  190. ) ;
  191.  
  192. void far twindow::winmove                     // Moves window to new position
  193. (
  194.    int row,                                  // Topleft corner's new position
  195.    int col
  196. ) ;
  197.  
  198. void far twindow::winscroll                      // Moves window 1 space only
  199. (
  200.    char direction                        // U: up  D: down  L: left  R: right
  201. ) ;
  202.  
  203. bool far twindow::winonedges       // Checks if position is on window's edges
  204. (
  205.    int      row,                                                  // Position
  206.    int      col,
  207.    int huge *offsetrow=NULL,            // Offset to window's top left corner
  208.    int huge *offsetcol=NULL
  209. ) ;
  210.  
  211. bool far twindow::wininside         // Checks if position is in window's area
  212. (
  213.    int      row,                                                  // Position
  214.    int      col,
  215.    int huge *offsetrow=NULL,            // Offset to window's top left corner
  216.    int huge *offsetcol=NULL
  217. ) ;
  218.  
  219. input_info far twindow::wininput // Gets input from window fields and buttons
  220. (
  221.    input_info ii                                         // input_info struct
  222. ) ;
  223.  
  224. void far twindow::fieldsetcolors                       // Sets fields' colors
  225. (
  226.    int back=BLUE,                                 // Fields' background color
  227.    int foreon=WHITE,                  // Fields' foreground color when active
  228.    int foreoff=LIGHTCYAN            // Fields' foreground color when inactive
  229. ) ;
  230.  
  231. void far twindow::fieldcreate                       // Creates an input field
  232. (
  233.    int       row,                                        // Input field's row
  234.    int       col,                                        // Input field's col
  235.    int       answerlength,                         // Answers' maximum length
  236.    int       length,                        // Input field's length in window
  237.    int       ftr,                        // Input field's filter number (0-4)
  238.    char huge *xtraftr,                      // Extra chars to use with filter
  239.    bool      capsflag,         // If TRUE, all input is switched to uppercase
  240.    bool      nullflag,                    // If TRUE, can enter a null string
  241.    char huge *defaultasw,                                   // Default answer
  242.    char huge *sltext,                       // Statusline text for this field
  243.    int       hlpctx=EV_NOHLPCTX                        // Help context number
  244. ) ;
  245.  
  246. void far twindow::fieldsetasw               // Sets default answer in a field
  247. (
  248.    char huge *answer,                        // Default answer for this field
  249.    int       fieldnb                                     // Field's ID number
  250. ) ;
  251.  
  252. void far twindow::fieldgetasw                        // Gets a field's answer
  253. (
  254.    char huge *dest,                        // Destination to copy answer's to
  255.    int       fieldnb                                     // Field's ID number
  256. ) ;
  257.  
  258. input_info far twindow::fieldinput               // Gets input from one field
  259. (
  260.    int fieldnb                           // Field's number, to get input from
  261. ) ;
  262.  
  263. void far twindow::buttonsetcolors                    // Sets buttons's colors
  264. (
  265.    int back=GREEN,                               // Button's background color
  266.    int foreon=WHITE,                 // Button's foreground color when active
  267.    int foreoff=BLACK,              // Button's foreground color when inactive
  268.    int high=YELLOW                       // Button's highlight color (hotkey)
  269. ) ;
  270.  
  271. void far twindow::buttoncreate               // Creates and displays a button
  272. (
  273.    int       row,                                             // Button's row
  274.    int       col,                                             // Button's col
  275.    char huge *name,                                          // Button's name
  276.    int       buttonkey,                                    // Button's hotkey
  277.    char huge *sltext=NULL,             // Button's associated statusline text
  278.    int       hlpctx=EV_NOHLPCTX                        // Help context number
  279. ) ;
  280.  
  281. void far twindow::buttonsetavail        // Sets availability flag of a button
  282. (
  283.    int  buttonkey,                                         // Button's hotkey
  284.    bool available=TRUE               // TRUE: available  FALSE: not available
  285. ) ;
  286.  
  287. input_info far twindow::buttoninput        // Waits for a button to be pushed
  288. (
  289.    input_info userinput,                              // User's initial input
  290.    bool       first=TRUE                      // TRUE: Makes 1st button alive
  291. ) ;
  292.  
  293.  
  294. private:
  295.  
  296. void far twindow::winreset () ;                 // Resets window's attributes
  297.  
  298. void twindow::winsavescreen () ; // Saves screen under window and its shadows
  299.  
  300. void far twindow::winrestorescreen () ;// Restores scr & shadows under window
  301.  
  302. void twindow::winhide () ;                        // Temporarily hides window
  303.  
  304. void twindow::winunhide () ;                               // Unhides windows
  305.  
  306. tbutton huge* twindow::buttonexist            // Checks if this button exists
  307. (
  308.    int buttonkey                                              // Button's key
  309. ) ;
  310.  
  311. void far twindow::buttondraw                                // Draws a button
  312. (
  313.    int  buttonkey,                                         // Button's hotkey
  314.    bool alive=FALSE,                         // TRUE: Alive  FALSE: Not Alive
  315.    bool pushed=FALSE                        // TRUE: Pushed FALSE: Normal pos
  316. ) ;
  317.  
  318. void far twindow::buttondrawall () ;               // Redraws all the buttons
  319.  
  320. void far twindow::buttonpush                     // Pushes one of the buttons
  321. (
  322.    int buttonkey                                           // Button's hotkey
  323. ) ;
  324.  
  325. } ;
  326.  
  327.  
  328. // End Header File ----------------------------------------------------------
  329.  
  330. #endif
  331.